Participating media baking

ABSTRACT

According to one embodiment, a method includes identifying a scene to be rendered, pre-computing one or more lighting elements within the scene, including creating a plurality of light scattering tables, performing, during the pre-computing, a computation of light extinction and light in-scattering within participating media of the scene, utilizing the plurality of light scattering tables, and during a ray tracing of the scene, determining a homogeneous scattering coefficient for spatially homogeneous media of the scene, and applying to the spatially homogeneous media of the scene one of the plurality of light scattering tables, where each of the plurality of light scattering tables corresponds to a single homogeneous scattering coefficient, and a table lookup is adjusted for the one of the plurality of light scattering tables utilizing an analytic correction factor in order to apply the one of the plurality of light scattering tables with a different homogeneous scattering coefficient.

FIELD OF THE INVENTION

The present invention relates to computer graphics rendering, and moreparticularly to pre-computation processes that are performed prior toreal-time graphics rendering.

BACKGROUND

One goal of computer graphics rendering is to achieve results that areaccurate and realistic. Accounting for light extinction and lightin-scattering occurring within participating media of a scene helpsachieve these accurate and realistic results. However, traditionalrendering methods fail to consider light extinction and lightin-scattering within participating media in a fast, efficient manner.

SUMMARY

A computer program embodied on a tangible computer readable mediumincludes computer code for identifying a scene to be rendered, computercode for pre-computing one or more lighting elements within the scene,including creating a plurality of light scattering tables, computer codefor performing, during the pre-computing, a computation of lightextinction and light in-scattering within participating media of thescene, utilizing the plurality of light scattering tables, and computercode for, during a ray tracing of the scene, determining a homogeneousscattering coefficient for spatially homogeneous media of the scene, andapplying to the spatially homogeneous media of the scene one of theplurality of light scattering tables, where each of the plurality oflight scattering tables corresponds to a single homogeneous scatteringcoefficient, and a table lookup is adjusted for the one of the pluralityof light scattering tables utilizing an analytic correction factor inorder to apply the one of the plurality of light scattering tables witha different homogeneous scattering coefficient.

According to another embodiment, a method includes identifying a sceneto be rendered, pre-computing one or more lighting elements within thescene, including creating a plurality of light scattering tables,performing, during the pre-computing, a computation of light extinctionand light in-scattering within participating media of the scene,utilizing the plurality of light scattering tables, and during a raytracing of the scene, determining a homogeneous scattering coefficientfor spatially homogeneous media of the scene, and applying to thespatially homogeneous media of the scene one of the plurality of lightscattering tables, where each of the plurality of light scatteringtables corresponds to a single homogeneous scattering coefficient, and atable lookup is adjusted for the one of the plurality of lightscattering tables utilizing an analytic correction factor in order toapply the one of the plurality of light scattering tables with adifferent homogeneous scattering coefficient.

A system according to another embodiment includes a processor foridentifying a scene to be rendered, pre-computing one or more lightingelements within the scene, including creating a plurality of lightscattering tables, performing, during the pre-computing, a computationof light extinction and light in-scattering within participating mediaof the scene, utilizing the plurality of light scattering tables, andduring a ray tracing of the scene, determining a homogeneous scatteringcoefficient for spatially homogeneous media of the scene, and applyingto the spatially homogeneous media of the scene one of the plurality oflight scattering tables, where each of the plurality of light scatteringtables corresponds to a single homogeneous scattering coefficient, and atable lookup is adjusted for the one of the plurality of lightscattering tables utilizing an analytic correction factor in order toapply the one of the plurality of light scattering tables with adifferent homogeneous scattering coefficient.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates a network architecture, in accordance with onepossible embodiment.

FIG. 2 illustrates an exemplary system, in accordance with oneembodiment.

FIG. 3 illustrates a method for implementing participating media baking,in accordance with one embodiment.

FIG. 4 illustrates a method for creating light scattering tables, inaccordance with one embodiment.

FIG. 5 illustrates a method for performing media baking for spatiallyhomogeneous media, in accordance with one embodiment.

FIG. 6 illustrates a method for performing media baking for spatiallyheterogeneous media, in accordance with one embodiment.

FIG. 7 illustrates an exemplary volume intersection analysis fordetermining a scattering coefficient for heterogeneous media, inaccordance with one embodiment.

DETAILED DESCRIPTION

The following description is made for the purpose of illustrating thegeneral principles of the present invention and is not meant to limitthe inventive concepts claimed herein. Further, particular featuresdescribed herein can be used in combination with other describedfeatures in each of the various possible combinations and permutations.

Unless otherwise specifically defined herein, all terms are to be giventheir broadest possible interpretation including meanings implied fromthe specification as well as meanings understood by those skilled in theart and/or as defined in dictionaries, treatises, etc.

It must also be noted that, as used in the specification and theappended claims, the singular forms “a,” “an” and “the” include pluralreferents unless otherwise specified.

FIG. 1 illustrates a network architecture 100, in accordance with onepossible embodiment. As shown, at least one network 102 is provided. Inthe context of the present network architecture 100, the network 102 maytake any form including, but not limited to a telecommunicationsnetwork, a local area network (LAN), a wireless network, a wide areanetwork (WAN) such as the Internet, peer-to-peer network, cable network,etc. While only one network is shown, it should be understood that twoor more similar or different networks 102 may be provided.

Coupled to the network 102 is a plurality of devices. For example, aserver computer 104 and an end user computer 106 may be coupled to thenetwork 102 for communication purposes. Such end user computer 106 mayinclude a desktop computer, laptop computer, and/or any other type oflogic. Still yet, various other devices may be coupled to the network102 including a mobile device 108 (e.g., a tablet, a portable gamingdevice, etc.), a mobile phone device 110, a gaming console 112 (e.g., adedicated console, a media device that enables gameplay, etc.), etc.

FIG. 2 illustrates an exemplary system 200, in accordance with oneembodiment. As an option, the system 200 may be implemented in thecontext of any of the devices of the network architecture 100 of FIG. 1.Of course, the system 200 may be implemented in any desired environment.

As shown, a system 200 is provided including at least one centralprocessor 201 which is connected to a communication bus 202. The system200 also includes main memory 204 [e.g. random access memory (RAM),etc.]. The system 200 also includes a graphics processor 206 and adisplay 208.

The system 200 may also include a secondary storage 210. The secondarystorage 210 includes, for example, a hard disk drive and/or a removablestorage drive, representing a floppy disk drive, a magnetic tape drive,a compact disk drive, etc. The removable storage drive reads from and/orwrites to a removable storage unit in a well-known manner.

Computer programs, or computer control logic algorithms, may be storedin the main memory 204, the secondary storage 210, and/or any othermemory, for that matter. Such computer programs, when executed, enablethe system 200 to perform various functions (to be set forth below, forexample). One or more computer programs may be embodied on a tangiblecomputer readable medium. Examples of tangible computer readable mediainclude, but are not limited to, memory 204, storage 210, volatile ornon-volatile storage, etc. Additional examples of tangible computerreadable media include, but are not limited to, portable storage mediasuch as a disc, a cartridge, a non-volatile random access memory card,etc. Tangible computer readable media may also be non-transitory.

FIG. 3 illustrates a method 300 for implementing participating mediabaking, in accordance with one embodiment. As an option, the method 300may be carried out in the context of the details of FIGS. 1-2. Ofcourse, however, the method 300 may be carried out in any desiredenvironment. Further, the aforementioned definitions may equally applyto the description below.

As shown in operation 302, a scene to be rendered is identified. In oneembodiment, the scene may include one or more light sources, one or moreobjects, etc. For example, the scene may include geometry, a viewpoint,one or more textures, lighting information, shading information, etc. Inanother embodiment, the scene may include a portion of a video game. Inyet another embodiment, the rendering may include a process ofgenerating an image from a model, utilizing one or more computerprograms.

Additionally, as shown in operation 304, one or more lighting elementswithin the scene are pre-computed. In one embodiment, the one or morelighting elements may include indirect light (e.g., global illumination,etc.) within the scene. In another embodiment, the pre-computing mayinclude performing one or more baking operations. For example, thebaking operations may include precomputation operations that areperformed prior to a real-time rendering of the scene (e.g., a raytracing of the scene, etc.). In another example, the results of thebaking operations may be stored in one or more lighting maps. In yetanother example, the results of the baking operations may be utilizedduring the real-time rendering of the scene.

Further, as shown in operation 306, a computation of light extinctionand light in-scattering within participating media of the scene isperformed during the pre-computing, utilizing a plurality of lightscattering tables. In one embodiment, the computation of lightextinction and light in-scattering associated with participating mediamay be performed during the baking process. In another embodiment, theparticipating media may include media within a scene that affects lightthat travels through the media. For example, the participating media mayinclude elements within the scene such as fog, clouds, smoke, water,etc. In another example, the light travelling through the participatingmedia may be absorbed, out-scattered, emitted, in-scattered, etc. In yetanother example, the participating media may include spatiallyheterogeneous media and/or spatially homogeneous media.

Further still, in one embodiment, the light extinction may include lightabsorption and light out-scattering within the participating media. Inanother embodiment, the computation of light extinction and lightin-scattering within participating media may be performed during thepre-computing in an accelerated manner.

Also, in one embodiment, each of the plurality of light scatteringtables may identify a spherical distribution of in-scattered light for apredetermined point during a simulation of indirect light. For example,each light scattering table may identify zonal harmonics (ZH) of anin-scattering impulse response. In another embodiment, each lightscattering table may be created by parameterizing the in-scatteringimpulse response as a function of distance (for point light (PL) anddirectional light (DL)). In yet another embodiment, each lightscattering table may be created by parameterizing the in-scatteringimpulse response as a function of distance and angle (for a differentialarea light such as a differential patch light (DPL)).

In addition, in one embodiment, each light scattering table may becreated by projecting a function into ZH at a predetermined position,where the function includes a spherical integral of the unoccludedaccumulated in-scattered radiance at the predetermined position. Inanother embodiment, one or more of the plurality of light scatteringtables may be queried during the baking process. For example, during thebaking/pre-computing, one or more lookups may be performed on one ormore of the light scattering tables.

Furthermore, in one embodiment, each of the plurality of lightscattering tables may be associated with a predetermined light type. Inanother embodiment, the light types may include point light (PL),directional light (DL), differential patch light (DPL), etc. Forexample, the point light may include a light source in space. In anotherexample, the directional light may include a light source that isinfinitely far away that is constantly coming from one direction (e.g.,sun/skylight). In yet another example, the differential patch light mayinclude light that reflects off a surface.

Further still, in one embodiment, each of the plurality of lightscattering tables may address spatially homogeneous media. For example,the participating media may include spatially homogeneous media that isuniform throughout. For instance, scattering parameters may beindependent of location within the homogeneous media. In this way,homogeneous media may have a constant scattering coefficient.

In another embodiment, each table may store results of projecting asignal (e.g., a light signal associated with a predetermined light type)onto ZH for a varying scattering coefficient value, distance value, andangle value. In this way, during baking/pre-computing, a lookup may beperformed within the light scattering tables to determine an amount oflight energy produced within the participating media. This amount oflight energy may be used to compute light extinction and lightin-scattering within participating media of the scene. For example, theamount of light energy may be applied to one or more formulas and/orsampling methods used to determine light extinction and lightin-scattering within the participating media of the scene.

Also, in one embodiment, each of the light scattering tables may addressspatially heterogeneous media. For example, the participating media mayinclude spatially heterogeneous media that is not uniform throughout.For instance, scattering parameters may vary or may be dependent on alocation within the heterogeneous media.

In another embodiment, light scattering tables corresponding to each ofa plurality of homogeneous scattering coefficients may be determinedduring the pre-computing. For example, during ray tracing of the scene,a homogeneous scattering coefficient may be determined for spatiallyhomogeneous media within the scene. A previously determined lightscattering table corresponding to the homogeneous scattering coefficientmay then be applied to the homogeneous media of the scene during the raytracing.

In another example, during ray tracing of the scene, spatiallyheterogeneous media within the scene may be approximated as spatiallyhomogeneous media within the scene by performing a volume intersectionfor each light ray associated with such participating media of the sceneto determine a corresponding homogeneous scattering coefficient for thelight ray, where the homogeneous scattering coefficient for the lightray is included within the plurality of homogeneous scatteringcoefficients. A previously determined light scattering tablecorresponding to the homogeneous scattering coefficient for each lightray may then be applied to the heterogeneous media of the scene duringthe ray tracing. In this way, a per-ray homogeneous coefficient may beused to simulate spatially heterogeneous media and/or spatiallyhomogeneous media.

Additionally, in one embodiment, the light scattering tables may accountfor both single scattering and multiple scattering. For example, singlescattering may include an instance where a light ray experiences asingle scattering event at a point between the source and destination(e.g., eye, etc.). In another example, multiple scattering may includean instance where a light ray experiences multiple scattering events atmultiple points between the source and destination (e.g., eye, etc.).

Further, in one embodiment, variance reduction may be performed withinthe plurality of light scattering tables. For example, performingvariance reduction may include performing equiangular sampling alongeach path ray when creating each light scattering table. In anotherexample, performing variance reduction may include performingdirectional importance sampling when creating each light scatteringtable.

Further still, in one embodiment, different parameterizations may beperformed for different light types when creating the plurality of lightscattering tables. In another embodiment, a light scattering table for asingle scattering coefficient may be used with any other scatteringcoefficient with no approximation error (e.g., by adjusting a tablelookup, by utilizing a correction factor such as an analytic correctionfactor, etc.). For example, creating the plurality of light scatteringtables may include generating a single light scattering table for eachof a plurality of different light types (e.g., PL, DL, DPL, etc.), whereeach light scattering table is associated with a first homogeneousscattering coefficient. Additionally, a table lookup may be adjustedutilizing an analytic correction factor in order to utilize an existinglight scattering table with a second homogeneous scattering coefficient.The analytic correction factor may act as remapping logic and may modifyone or more of distance and lighting values of the existing lightscattering table in order to utilize the existing light scattering tablewith the second homogeneous scattering coefficient. In yet anotherembodiment, the plurality of light scattering tables may address bothisotropic and anisotropic phase functions.

In this way, the plurality of light scattering tables may be referencedduring the pre-computing of one or more lighting elements within thescene in order to compute light extinction and light in-scatteringwithin participating media of the scene in an accelerated manner.

More illustrative information will now be set forth regarding variousoptional architectures and uses in which the foregoing method may or maynot be implemented, per the desires of the user. It should be stronglynoted that the following information is set forth for illustrativepurposes and should not be construed as limiting in any manner. Any ofthe following features may be optionally incorporated with or withoutthe exclusion of other features described.

FIG. 4 illustrates a method 400 for creating light scattering tables, inaccordance with one embodiment. As an option, the method 400 may becarried out in the context of the details of FIGS. 1-2. Of course,however, the method 400 may be carried out in any desired environment.Further, the aforementioned definitions may equally apply to thedescription below.

As shown in operation 402, an impulse response of in-scattering of ascene is projected into spherical harmonics (SH) or zonal harmonics (ZH)and results are precomputed for a plurality of different distances andangles within the scene.

Additionally, as shown in operation 404, the results of the precomputingare stored in one or more light scattering tables for use during one ormore baking operations. In this way, the one or more light scatteringtables may be queried during one or more baking operations prior to areal-time rendering of a scene.

FIG. 5 illustrates a method 500 for performing media baking forspatially homogeneous media, in accordance with one embodiment. As anoption, the method 500 may be carried out in the context of the detailsof FIGS. 1-2. Of course, however, the method 500 may be carried out inany desired environment. Further, the aforementioned definitions mayequally apply to the description below.

As shown in operation 502, a scene to be rendered is identified.Additionally, as shown in operation 504, one or more lighting elementsare precomputed within the scene, where the precomputing includescreating a plurality of light scattering tables.

Further, as shown in operation 506, during the pre-computing, acomputation of light extinction and light in-scattering is performedwithin participating media of the scene, utilizing the plurality oflight scattering tables. Further still, as shown in operation 508,during a ray tracing of the scene, a homogeneous scattering coefficientis determined for spatially homogeneous media of the scene. Also, asshown in operation 510, during the ray tracing of the scene, one of theplurality of light scattering tables is applied to the spatiallyhomogeneous media of the scene, where each of the plurality of lightscattering tables corresponds to a single homogeneous scatteringcoefficient, and a table lookup is adjusted for the one of the pluralityof light scattering tables utilizing an analytic correction factor inorder to apply the one of the plurality of light scattering tables witha different homogeneous scattering coefficient (e.g., when thedetermined homogeneous scattering coefficient is different from thesingle homogeneous scattering coefficient corresponding to the lightscattering table).

FIG. 6 illustrates a method 600 for performing media baking forspatially heterogeneous media, in accordance with one embodiment. As anoption, the method 600 may be carried out in the context of the detailsof FIGS. 1-2. Of course, however, the method 600 may be carried out inany desired environment. Further, the aforementioned definitions mayequally apply to the description below.

As shown in operation 602, a scene to be rendered is identified.Additionally, as shown in operation 604, one or more lighting elementsare precomputed within the scene, where the precomputing includescreating a plurality of light scattering tables.

Further, as shown in operation 606, during the pre-computing, acomputation of light extinction and light in-scattering is performedwithin participating media of the scene, utilizing the plurality oflight scattering tables. Further still, as shown in operation 608,during a ray tracing of the scene, spatially heterogeneous media of thescene is approximated as spatially homogeneous media of the scene byperforming a volume intersection for each light ray associated with thespatially heterogeneous media of the scene to determine a homogeneousscattering coefficient for the light ray, where the homogeneousscattering coefficient for the light ray is included within theplurality of homogeneous scattering coefficients. Also, as shown inoperation 610, during the ray tracing of the scene, one of the pluralityof light scattering tables is applied to the spatially heterogeneousmedia of the scene, where each of the plurality of light scatteringtables corresponds to a single homogeneous scattering coefficient, and atable lookup is adjusted for the one of the plurality of lightscattering tables utilizing an analytic correction factor in order toapply the one of the plurality of light scattering tables with adifferent homogeneous scattering coefficient (e.g., when the determinedhomogeneous scattering coefficient is different from the singlehomogeneous scattering coefficient corresponding to the light scatteringtable).

Accounting for light extinction and in-scattering during baking isvaluable during rendering. For example, rendering engines may considerextinction and in-scattering from the point of view of the eye. However,surfaces don't get this attention and as you get closer to a surface inmedia, it may be presented as unrealistically bright. By addressingextinction and in-scattering during the baking process, lighting issuesmay be improved during surface rendering involving participating media.

Participating Media

Table 1 includes a formula illustrating how light interacts withparticipating media, in accordance with one embodiment. Of course, itshould be noted that the formula shown in Table 1 is set forth forillustrative purposes only, and thus should not be construed as limitingin any manner.

TABLE 1${\left( {\overset{\rightarrow}{\omega} \cdot \nabla} \right){L\left( x\rightarrow\overset{\rightarrow}{\omega} \right)}} = {{- \underset{\underset{extinction}{︸}}{\underset{\underset{absorption}{︸}}{{\sigma_{a}(x)}{L\left( x\rightarrow\overset{\rightarrow}{\omega} \right)}} - \underset{\underset{{out}\text{-}{scattering}}{︸}}{{\sigma_{s}(x)}{L\left( x\rightarrow\overset{\rightarrow}{\omega} \right)}}}} + \mspace{430mu}\underset{\underset{emission}{︸}}{{\sigma_{a}(x)}{L_{e}\left( x\rightarrow\overset{\rightarrow}{\omega} \right)}} + \underset{\underset{{in}\text{-}{scattering}}{︸}}{{\sigma_{s}(x)}{L_{i}\left( x\rightarrow\overset{\rightarrow}{\omega} \right)}}}$

Table 2 illustrates exemplary participating media parameters, inaccordance with one embodiment. Of course, it should be noted that theparameters shown in Table 2 are set forth for illustrative purposesonly, and thus should not be construed as limiting in any manner.

TABLE 2 Parameter Value scattering coefficient govern- σ_(s) ing out-and in-scattering absorption coefficient σ_(a) extinction coefficientσ_(t) = σ_(s) + σ_(a) phase function${{\rho\left( {x,\overset{\rightarrow}{\omega_{t}},\overset{\rightarrow}{\omega}} \right)}\mspace{14mu}{with}\mspace{14mu}{isotropic}\mspace{11mu}\rho} = \frac{1}{4\pi}$transmittance through T_(r) (x ↔ x_(s)) = e^(−σ) ^(t) ^(d) _(x↔x) _(s) ,media with d_(x↔x) _(s) the distance between x and x_(s) in-scatteringsource factor L_(i)(x_(t), {right arrow over (ω)} )= ∫_(Ω) _(4π)ρ(x_(t), {right arrow over (ω)}_(t), {right arrow over (ω)})L(x_(t),{right arrow over (ω)}_(t))d{right arrow over (ω)}_(t), at positionx_(t) in direction {right arrow over (ω)}

Precomputation

In one embodiment, light scattering tables (e.g., tables of ZH ofin-scattering impulse response, etc.) may be precomputed, where suchtables may be fast and easy to query at bake time (e.g., utilizinglinear interpolation over the table). In another embodiment, thein-scattering impulse response may be parametrized as a function ofdistance (and angle for DPL).

In one embodiment, the function projected onto ZH at position x,f(x)=∫_(Ω) _(4π) L(x,{right arrow over (ω)})d{right arrow over (ω)}, maybe the spherical integral of the unoccluded accumulated in-scatteredradiance:

${{L\left( {x,\overset{\rightarrow}{w}} \right)} = {\int_{0}^{\infty}{{T_{r}\left( x\leftrightarrow x_{t} \right)}{\sigma_{s}\left( x_{t} \right)}{L_{i}\left( {x_{t},{- \overset{\rightarrow}{w}}} \right)}{dt}}}},$where L_(i)(x_(t),{right arrow over (ω)}) is defined as thein-scattering source factor at position x_(t) in direction {right arrowover (ω)}:L _(i)(x _(t),{right arrow over (ω)})=∫_(Ω) _(4π) ρ(x _(t),{right arrowover (ω)}_(t),{right arrow over (ω)})L(x _(t),{right arrow over(ω)}_(t))d{right arrow over (ω)} _(t).

Computing in-Scattering for Homogeneous Media

In one embodiment, in-scattering may be computed utilizing equi-angularsampling. In another embodiment, in-scattering may be computed utilizingCone-Anti-Cone directional importance sampling, according to thefollowing formula:

${x = {\sum\limits_{i}{\frac{c_{i}}{c_{0}} \cdot {\int_{0}^{2\pi}{\int_{0}^{a}{y_{l}^{0}{\sin(\theta)}d\;\theta\; d\;\phi}}}}}},$where x includes the percentage of samples to distribute in the cone,and 1-x is the ratio of samples given to the anti-cone. In oneembodiment, the above formula may be solved for the best ratio x (e.g.,utilizing parabolic interpolation, etc.).

Additionally, in one embodiment, density sampling may be performed untilthe last scattering event, and then IS methods may be used to go back tothe light source. In another embodiment, Cone/Anti-Cone sampling may beused for the first and last spherical integrations. In yet anotherembodiment, an in-scattering ZH fit may be used to sample inscattering.

Further, in one embodiment, there may be a constant scatteringcoeffecient a over an infinite homogeneous media. For each type of light(e.g., point, directional, differential patch, etc.), the associatedsignal may be projected onto ZH, for varying sigma, distance, and angle.Results may then be tabulated, with one table being created per lighttype.

Further still, in one embodiment, a DPL's signal may be circularlysymmetric for a direction along the normal of the patch. A shift anglemay include a parameterization of the optimal signal direction to encodeas a ZH (e.g., the lobe axis). In another embodiment, encoding may usethe frame defined by the source, the vector from the source to thereceiver, and the normal (since the optimal lobe may always be on theplane intersecting the source in the span of those two vectors). The ZHmay be fit over the DLP's signal, and the ZH main axis may be foundusing least-square interpolation between light direction and the SH'soptimal linear direction. An additional shift angle may also be stored.

Approximating Heterogeneous Media

In one embodiment, heterogeneous media may have spatially varyingdensity. For example, the heterogeneous media may be procedural, mayfrom a data structure (AABB, OBB, Octree, etc.), etc. In anotherembodiment, every ray passing through heterogeneous media may need tounderstand how the density varies along it in order to effectivelysample steps (e.g., by performing density sampling according to the cdfof σ) and compute the source factor at those positions.

Additionally, in one embodiment, heterogeneous media may be approximatedas directionally varying homogeneous media. For example, each ray shotfrom a receiver point may possess a single set of scattering andabsorption coefficients. This reduction is exact for directtransmission, as the transmittance is:

${e^{- \frac{\sum\limits_{i}{\sigma_{i}d_{i}}}{D}}=={\prod\limits_{i}e^{{- \sigma_{i}}d_{i}}}},$and the product of the individual transmittances is equal to thetransmittance of the average sigma for a given ray length. Forin-scattering, this may be an approximation, as in-scattered rays maypass through non-collinear media locations. In another embodiment, asingle extinction coefficient

$\sigma_{t} = \frac{\sum\limits_{i}{\sigma_{i}d_{i}}}{D}$may be approximated over a ray of length D. In this way, a per-rayhomogeneous coefficient may be used to simulate spatially heterogeneousmedia.

FIG. 7 illustrates an exemplary volume intersection analysis 700 fordetermining a scattering coefficient for heterogeneous media, accordingto one embodiment. As shown, the heterogeneous media is viewed as aplurality of volumes 702A-C that are identified as being intersected bya ray 704 originating at a receiver point 706 and terminating at a hitpoint 708. Associated scattering coefficients 510A-D are determined,based on the intersection, and these coefficients 710A-D are averaged inorder to determine a scattering coefficient for the heterogeneous media.

Phase Function

In one embodiment, an exemplary phase function for performing bakedextinction and in-scattering may include:

${\rho\left( {\cos(\theta)} \right)} = {\sum\limits_{i}{w_{i}{b_{i}\left( {\cos(\theta)} \right)}}}$for single scattering. In another embodiment, a similarity theory atσ_(t)(1−g) may be applied, as it may be better fitted for higher-Kscattering events since it may be modeled well for the 0th moment. Inanother embodiment, σ-remapping from an anisotropic to an isotropicphase function may be performed for impulse response type functions.

Additionally, in one embodiment, anisotropic phase functions may beaddressed by performing a precomputation independent of scattering. Atensor of coefficients may be used for multiple scattering events. Thismay be multiplied on multiple sides by phase function coefficients toobtain an incident impulse response for different phase functions.

Fitting in-Scattering to Zonal Harmonics

In one embodiment, in-scattering from PL and DL may be isotropicsignals. Their contribution may be projected directly to ZH. In anotherembodiment, in-scattering from DPL may be isotropic along the DPL'snormal axis but the signal may become anisotropic if gathered at a pointat an angle from that axis. In yet another embodiment, a shift distancemay be found by a parabolic search of fitting the DPL's sphericalharmonics (SH) to ZH at different main axes between the light directionand the optimal linear direction vector (−SH[3]; −SH[1]; SH[2]).

In this way, for PL and DL, an isotropic signal may be projected onto ZHdirectly. For DPL, the signal may be projected onto SH, and the mainaxis of incidence may be shifted in the patch normal's direction. A ZHmay be fit over the SH coefficients around this axis, and the ZHcoefficients as well as the shift distance may be stored.

Table Parametrization

In one embodiment, different parametrization may be utilized fordifferent light types. In another embodiment, independentparametrizations for close and far distances from the light may beapplied to fit the underlying data. For example, the distancedistribution may be between 1/d and 1/d², and the behavior may getcloser to one or the other depending on distance.

Additionally, in one embodiment, table parameterization may be linearover cos(θ) for DPL angles. The parameterization may be bounded betweencos(θ)=1 for the incident direction and cos(θ)=∈ for the most obliquedirection.

Further, in one embodiment, a gradient fit may be implemented for PL &DPL so that extrapolation may be possible when querying distances closerto a light than data is provided for. For those light types tables, theaverage gradient of the data may be identified over a small local range(e.g., half of the local (close distances) parametrization) and the sumof that gradient may be stored as well as the value at the second indexin the first index of those tables. When querying, negative weights maybe allowed so as to extrapolate from those two first indices' values. DLmay not store the gradient since the nature of the table makes it sothat lim_(x→0) L(x)=0.

Further still, in one embodiment, each table may store a headercontaining values pertaining to the table's parametrization. First, anumber of distance entries and a number of ZH bands may be stored in theheader. Each table may store its first, mid and last indices (nx0, nx1,nx2), as well as the distance values at those indices (x0, {right arrowover (ω)}, x2). DPL may also store the information related to angularsampling, such as a number of angle entries, and the value of cos(θ) atthe first and last indices, cos(θ₀) and cos(θ_(∈)) respectively.

Query & Baking

In one embodiment, the tables may be queried at bake time for everyradiance ray depending on the type of light and the type of receiver(e.g., scalar: lightmap texel, vertex, or vector: SH probe, etc.). Inanother embodiment, from a query distance (and angle for DPL), themodified distance and weight may be computed depending on the table'su-ratio. The modified distance d may then be used to find the index andweight for the linear interpolation in the table. Since twoparametrizations may be used per table, d may first be compared with thex0, x1, x2 bounds to determine which parametrization to lookup, and thefloating-point index i=a_(α)*d+b_(α) may be returned. For DPL, thecosine of the angle between the query direction and the patch's normalmay be used as a linear weight between the two cosine bounds cos(θ₀) andcos(θ_(∈)) to find the angular index.

Additionally, in one embodiment, those indices may be used to lookup thetables, and linear (or bilinear for DPL) interpolation between discreteindices may be performed. Since the tables may be constructed to allowinterior extrapolation at table boundaries, the lookup may solve thoseboundary cases. In another embodiment, when considering multiple bouncesof in-scattering, lookups may be performed in each bounce tablesequentially, while accumulating the coefficients and updating theper-bounce weight as the lookups progress.

Further, in one embodiment, for a DPL case, the computation may bealtered when considering multiple bounces. For example, each bounce mayhave a different shift distance, and thus a different axis of SHevaluation. In this case, one SH evaluation may be performed per bouncebefore accumulation. In another embodiment, for the vector case, thereceiver may be a SH itself, and the queried coefficients

$c_{l}^{m} = {\sum\limits_{l}{\sum\limits_{m}{y_{l}^{m}z_{l}}}}$may be directly added. In another embodiment, for a scalar case, thereceiver may be a surface with a normal, and the queried ZH may beconvolved with the cosine between the surface's normal and the lightdirection. For example, the integral of a ZH function may be computed ina direction without expanding it to full ZH (e.g., an 11-coefficient ZHmay expand to 121 coefficients for SH). This may minimize a number ofcoefficients needed to compute the ZH function.

Further still, in one embodiment, both direct attenuation andin-scattering may be added, such as L(p)=∫_(Ω)L_(i)(p,{right arrow over(ω)})(T_(r)(p,{right arrow over (ω)})+InScattering(p,{right arrow over(ω)}))d{right arrow over (ω)}, where L_(i)(p,{right arrow over (ω)}) isa wavelength-dependent function.

Varying the Scattering Coefficient

In one embodiment, the light scattering tables may contain the impulseresponse of in-scattering from a single light projected onto ZH at asingle receiver point x. As a result, the projected function may becomputed for a specific extinction coefficient σt. In anotherembodiment, the projected function may be interpolated from severaltables generated from different σt, but in one embodiment, the behaviorof the RTE may be viewed according to σ.

For example, if σ_(s) is modified, both the transmittance terms T_(r)and the scattering probability for the in-scattering may change. ForT_(r), the exponentiated term −σ_(t) d may behaves predicatively if theσ changes, and modifying U may amount to inversely modifying d. Thus,e^(−σ) ^(a) ^(d) ^(a) =e^(−σ) ^(b) ^(d) ^(b) when

$d_{a =}\frac{\sigma_{b}}{\sigma_{a}}{d_{b}.}$From this observation, computing the in-scattering impulse responses forσ_(t)=σ_(b) and querying the resulting tables with

$d_{q} = {\frac{\sigma_{a}}{\sigma_{b}}d_{a}}$may solve the transmittance terms of the integrals.

Additionally, in one embodiment, each scattering event may have aprobability σ_(s). With a table computed with σ_(b), it may be necessaryto correct for this by a factor of

$\frac{\sigma_{a}}{\sigma_{b}},$which may be directly applied as a weight to the queried coefficients.This term may be called the σ-ratio. For punctual lights, thein-scattering may also incorporate the

$\frac{I_{0}}{d^{2}}$term. When querying the tables with the above d_(q), this attenuationfactor may be equally modified as

$\frac{I_{0}}{\left\lbrack {\frac{\sigma_{a}}{\sigma_{b}}d_{a}} \right\rbrack^{2}}.$This may be corrected for with an additional

$\frac{\sigma_{a}}{\sigma_{b}}\quad^{2}$weight.

In this way, for a single scattering event, a correction factor of

$\frac{\sigma_{a}}{\sigma_{b}}\quad^{3}$may be applied for punctual lights, and a correction factor of

$\frac{\sigma_{a}}{\sigma_{b}}$may be applied for directional lights. In term of integrals, theintegral of in-scattering over a full ray may be ∫₀ ^(D) ^(b)σ_(b)ρ(x_(b))L_(i)(x_(b))dx_(b), and the measure of the integral maycancel one of the σ-ratios.

Occlusion

In one embodiment, when looking at a peaky shape and solid angle (˜5-6deg) covered by lower-bounce in-scattering impulse response, consideringocclusion more than the direct occlusion to the light source may beavoided. For example, low-bounce in-scattering may be added wheneverdirect attenuation is computed. For higher-bounces in-scattering, thesignal may become much more diffuse at distances closer to the lightsource (e.g., as indicated by the ZH DC towering over the other bands).For this, an approximation to occlusion may be implemented. Since atthis point the signal may be ambient, an AO-type occlusion function maybe used to modulate the amount of added in-scattering.

Optimizations

In one embodiment, coarser sigma parametrization may be implemented. Forexample, instead of each ray computing its homogeneous σ, a coarserdirectional representation of σ may be used at each texel, cluster, etc.in a Cubemap/SH. Each ray may retrieve its extinction coefficient fromthis representation instead.

Additionally, in one embodiment, in-scattering may be computed on asubset of the rays used to compute radiance for a texel. Any uniformsubset

$\left( {M = {\frac{1}{K}N}} \right)$of the radiance rays used for a lightmap texel may computemultiple-bounce in-scattering in a separate integral, which may then bere-weighted by K to account for uncomputed ones.

Further, in one embodiment, one or more computations necessary atbake-time may be parallelized with SSE or AVX vector instructions. Thetable queries may be implemented using single-lane instructions. Inanother embodiment, multiple scattering may be implemented as ageometric series approximation Σ_(i)σ_(i)ρ_(i)f_(i)(d).

Further still, in one embodiment, taking cues from photon mapping,points in the medium may be distributed and their source factor may beevaluated. Those points may be translated and rotated around the mainlight axis (e.g., the light to integration point for PL and DL, thepatch normal for DPL, etc.). In another embodiment, connections may bemade afterwards to compute the in-scattering from them all to theintegration point.

Also, in one embodiment, the integration may be viewed as bi-directionalpath tracing, and photons may be traced from both the light and theintegration point and connect. In another embodiment, after severalbounces, a signal may become predominantly ambient for closer distancesto the light. As a result, only the ZH DC may be used, by finding thedistance cutoff point (in both bounce count and distances) where DC-onlyor every band may then be considered.

Variance Reduction

In one embodiment, for multiple scattering, at each scattering event, aconnection may be made to the light (e.g., via an explicit path), and 3Dintegration may be repeated (e.g., via an implicit path). In anotherembodiment, equiangular sampling may be performed along each path ray.For example, the samples may be proportional to the light's

$\frac{1}{d^{2}}$term. This may cancel a weak singularity for single scattering.

Additionally, in one embodiment, a robust Monte Carlo algorithm may beimplemented to reduce an outlier amount. For example, N passes ofintegrand computations may be made, and their SH coefficients may bestored. Additionally, the passes may be sorted according to the SH DC.The DC may be statistically analyzed to define small and large outliers,which may be removed from the computation. The expected value may thenbe computed from the remaining values.

In this way, the impulse response of scene in-scattering may beprojected into SH or ZH and may be precomputed for different distancesand angles. The results may be stored in precomputed tables that arequeried during baking.

It will be clear that the various features of the foregoing systemsand/or methodologies may be combined in any way, creating a plurality ofcombinations from the descriptions presented above.

While various embodiments have been described above, it should beunderstood that they have been presented by way of example only, and notlimitation. Thus, the breadth and scope of a preferred embodiment shouldnot be limited by any of the above-described exemplary embodiments, butshould be defined only in accordance with the following claims and theirequivalents.

What is claimed is:
 1. A computer program embodied on a non-transitorycomputer readable medium, comprising: computer code for identifying ascene to be rendered; computer code for pre-computing one or morelighting elements within the scene, including creating a plurality oflight scattering tables; computer code for performing, during thepre-computing, a computation of light extinction and light in-scatteringwithin participating media of the scene, utilizing the plurality oflight scattering tables; and computer code for, during a ray tracing ofthe scene: determining a homogeneous scattering coefficient forspatially homogeneous media of the scene, and applying to the spatiallyhomogeneous media of the scene one of the plurality of light scatteringtables, where each of the plurality of light scattering tablescorresponds to a single homogeneous scattering coefficient, and a tablelookup is adjusted for the one of the plurality of light scatteringtables utilizing an analytic correction factor in order to apply the oneof the plurality of light scattering tables with a different homogeneousscattering coefficient.
 2. The computer program of claim 1, wherein thepre-computing includes performing one or more baking operations prior tothe ray tracing of the scene.
 3. The computer program of claim 1,wherein the light extinction includes light absorption and lightout-scattering within the participating media of the scene.
 4. Thecomputer program of claim 1, wherein each of the plurality of lightscattering tables identifies a spherical distribution of in-scatteredlight for a predetermined point during a simulation of indirect light.5. The computer program of claim 1, wherein during the pre-computing,one or more lookups are performed on one or more of the plurality oflight scattering tables.
 6. The computer program of claim 1, whereinduring the pre-computing, a lookup is performed within the plurality oflight scattering tables to determine an amount of light energy producedwithin the participating media, where this amount of light energy isused to compute the light extinction and the light in-scattering withinthe participating media of the scene.
 7. The computer program of claim1, wherein each of the plurality of light scattering tables isassociated with a predetermined light type, the predetermined light typeincluding point light (PL), directional light (DL), or differentialpatch light (DPL).
 8. The computer program of claim 7, wherein each ofthe plurality of light scattering tables that is associated with PL orDL is created by parameterizing an in-scattering impulse response as afunction of distance.
 9. The computer program of claim 7, wherein eachof the plurality of light scattering tables that is associated with DPLis created by parameterizing an in-scattering impulse response as afunction of distance and angle.
 10. A method, comprising: identifying ascene to be rendered; pre-computing one or more lighting elements withinthe scene, including creating a plurality of light scattering tables;performing, during the pre-computing, a computation of light extinctionand light in-scattering within participating media of the scene,utilizing the plurality of light scattering tables; and during a raytracing of the scene: determining a homogeneous scattering coefficientfor spatially homogeneous media of the scene, and applying to thespatially homogeneous media of the scene one of the plurality of lightscattering tables, where each of the plurality of light scatteringtables corresponds to a single homogeneous scattering coefficient, and atable lookup is adjusted for the one of the plurality of lightscattering tables utilizing an analytic correction factor in order toapply the one of the plurality of light scattering tables with adifferent homogeneous scattering coefficient.
 11. The method of claim10, wherein the pre-computing includes performing one or more bakingoperations prior to the ray tracing of the scene.
 12. The method ofclaim 10, wherein the light extinction includes light absorption andlight out-scattering within the participating media of the scene. 13.The method of claim 10, wherein each of the plurality of lightscattering tables identifies a spherical distribution of in-scatteredlight for a predetermined point during a simulation of indirect light.14. The method of claim 10, wherein during the pre-computing, one ormore lookups are performed on one or more of the plurality of lightscattering tables.
 15. The method of claim 10, wherein during thepre-computing, a lookup is performed within the plurality of lightscattering tables to determine an amount of light energy produced withinthe participating media, where this amount of light energy is used tocompute the light extinction and the light in-scattering within theparticipating media of the scene.
 16. The method of claim 10, whereineach of the plurality of light scattering tables is associated with apredetermined light type, the predetermined light type including pointlight (PL), directional light (DL), or differential patch light (DPL).17. The method of claim 16, wherein each of the plurality of lightscattering tables that is associated with PL or DL is created byparameterizing an in-scattering impulse response as a function ofdistance.
 18. The method of claim 16, wherein each of the plurality oflight scattering tables that is associated with DPL is created byparameterizing an in-scattering impulse response as a function ofdistance and angle.
 19. A system, comprising: a processor for:identifying a scene to be rendered; pre-computing one or more lightingelements within the scene, including creating a plurality of lightscattering tables; performing, during the pre-computing, a computationof light extinction and light in-scattering within participating mediaof the scene, utilizing the plurality of light scattering tables; andduring a ray tracing of the scene: determining a homogeneous scatteringcoefficient for spatially homogeneous media of the scene, and applyingto the spatially homogeneous media of the scene one of the plurality oflight scattering tables, where each of the plurality of light scatteringtables corresponds to a single homogeneous scattering coefficient, and atable lookup is adjusted for the one of the plurality of lightscattering tables utilizing an analytic correction factor in order toapply the one of the plurality of light scattering tables with adifferent homogeneous scattering coefficient.
 20. The system of claim19, wherein the processor is coupled to memory via a bus.